From: Haozhong Zhang Date: Tue, 19 Jan 2016 15:07:39 +0000 (+0100) Subject: x86/time: scale host TSC in pvclock properly X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~1925 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=eab8a90be723d742d607aff2005ea0ab521bfd6a;p=xen.git x86/time: scale host TSC in pvclock properly This patch makes the pvclock return the scaled host TSC and corresponding scaling parameters to HVM domains if guest TSC is not emulated and TSC scaling is enabled. Signed-off-by: Haozhong Zhang Reviewed-by: Boris Ostrovsky --- diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index ec3f33e686..988403aedf 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -815,10 +815,18 @@ static void __update_vcpu_system_time(struct vcpu *v, int force) } else { - tsc_stamp = t->local_tsc_stamp; - - _u.tsc_to_system_mul = t->tsc_scale.mul_frac; - _u.tsc_shift = (s8)t->tsc_scale.shift; + if ( has_hvm_container_domain(d) && cpu_has_tsc_ratio ) + { + tsc_stamp = hvm_funcs.scale_tsc(v, t->local_tsc_stamp); + _u.tsc_to_system_mul = d->arch.vtsc_to_ns.mul_frac; + _u.tsc_shift = d->arch.vtsc_to_ns.shift; + } + else + { + tsc_stamp = t->local_tsc_stamp; + _u.tsc_to_system_mul = t->tsc_scale.mul_frac; + _u.tsc_shift = t->tsc_scale.shift; + } } _u.tsc_timestamp = tsc_stamp;